package engine.newUi 
{
	import engine.control.NxTablePageTurner;
	import engine.data.BindManage;
	import engine.data.ModelLocator;
	import engine.data.Record;
	import engine.flag.GameDefine;
	import engine.logic.SceneTransfer;
	import engine.logic.tips.TipsManage;
	import engine.net.event.CustomMsgEvent;
	import engine.net.messages.CustomToClientFlag;
	import engine.net.messages.CustomToServerFlag;
	import engine.net.mgr.SystemSender;
	import engine.tip.TipsMainLogic;
	import engine.ui.lite.BaseUI;
	
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.events.TimerEvent;
	import flash.text.StyleSheet;
	import flash.utils.Timer;
	
	import newx.BaseObject;
	import newx.com.ResManager;
	import newx.com.config.StaticIni;
	import newx.com.control.NxClip;
	import newx.com.control.button.NxButton;
	import newx.com.control.group.NxViewGroup;
	import newx.com.control.tab.NxTab;
	import newx.com.control.tab.NxTabEvent;
	import newx.com.control.table.NxTabelPos;
	import newx.com.control.table.NxTable;
	import newx.com.control.table.NxTableEvent;
	import newx.com.control.text.NxLabel;
	import newx.com.control.text.NxText;
	import newx.com.control.window.NxWindowEvent;
	
	/**
	 * ...
	 * @author WangHaiBo  www.woniu.com
	 */
	public class TaskListUI extends BaseUI 
	{
		public var giveStrTitle	:NxLabel;
		public var taskList		:NxTable;
		public var taskTab			:NxTab;
		public var backFrame_1		:MovieClip;
		//public var autoOverBtn		:NxButton;
		public var pageNumBack		:MovieClip;
		public var nextPage		:NxButton;
		public var purePage		:NxButton;
		public var pageNum			:NxLabel;
		public var leftTimeLb		:NxLabel;
//		public var leftTimeTxt		:NxLabel;
//		public var autoFTTime		:NxLabel;
		public var giveStrLabel	:NxLabel;
		public var equipPicGroup	:NxViewGroup;
		public var taskInfoText	:NxText;
		public var taskNeedText	:NxText;
//		public var equipInfoTxt	:NxLabel;
		//public var sendBtn			:NxButton;
		//public var overFrame		:MovieClip;
		public var checkBox		:MovieClip;
		public var label_1			:NxLabel;
		public var giveUpBtn		:NxButton;
		public var back1			:MovieClip;
		public var back2			:MovieClip;
		public var backFrame_2		:MovieClip
		public var tasbt			:NxButton;
		private var _prizeItemArr	:Array		=	[];
		private static var _self	:TaskListUI;
		private var _model			:ModelLocator;
		private var _bind			:BindManage;
		private var _haveTaskArray	:Array;
		private var _taskArray		:Array;
		private var _dayTaskArray	:Array;
		private var _haveTaskList	:int		=	-1;
		private var _taskLogic		:TaskLogic
		private var tablePageTurner	:NxTablePageTurner;
		private static var NOW_TASK:String		=	"NOW_TASK";
		private static var CAN_TASK:String		=	"CAN_TASK";
		private static var DAY_TASK:String		=	"DAY_TASK";
		
		private var _haveTaskStr:String	=	 StaticIni.getSwfLangStr("Task_CurTask") ; 
		private var _canTaskStr:String		=	StaticIni.getSwfLangStr("Task_AcceptTask") ; 
		private var _clickTaskItem :Object		=	null;
		
		//自动完成显示信息
		/**任务完成倒计时*/
		private var _taskOverTimer		:Timer	=	new Timer(1000);
		/**当前选中的任务完成时间*/
		private var _taskEndTime		:Number	=	-1;
		/**当前选中任务剩余时间*/
		private var _leftTime			:Number	=	-1;
		private var _autotime			:int;
		private var _autoTimer			:Timer	=	new Timer(1000); 
		/**校对次数*/
		private var _times				:int	=	0;
		private var _lineTaskType:int			=	-1;
		private var _linkTaskID	:int 			= -1;
		private var _linkTaskAuto	:Boolean	=	false;
		private var _showTabIndex:int			=	0;
		private var _frameSpace:Sprite;
		private var _tablePos:NxTabelPos;
		/***记录当前显示的任务ID**/
		private var _currTaskId:int;
		
		public function TaskListUI() 
		{
			
		}
		public static function getInstance():TaskListUI
		{
			if (_self == null) 
			{
				_self	=	new TaskListUI();
			}
			return _self;
		}
		override public function Init():void 
		{
			_frameSpace							=	new Sprite();
			_frameSpace.visible					=	false;
			_frameSpace.mouseEnabled			=	false;
	//		overFrame.mouseChildren	=	overFrame.mouseEnabled 	=	false;
			taskList.addChild(_frameSpace);
			//sendBtn.alpha	=	autoOverBtn.alpha	=	.7
			//sendBtn.x								=	206
			///autoOverBtn.x							=	148;
			//sendBtn.y	=	autoOverBtn.y			=	0;
			//overFrame.x	=	overFrame.visible		=	false;
			//sendBtn.visible	=	autoOverBtn.visible		=	false;
		//	_frameSpace.addChild(overFrame);
			//_frameSpace.addChild(autoOverBtn);
			//_frameSpace.addChild(sendBtn);
			_taskLogic							=	new TaskLogic();
			_model								=	ModelLocator.getInstance();
			_bind								=	BindManage.getInstance();
			
			_bind.BindRecord(_model.scene,"Task_Accepted",updataTaskTrack,updataTaskTrack);
			_bind.BindRecord(_model.scene,"Task_Record",updataTaskTrack,updataTaskTrack);
			_haveTaskArray						=	[];
			_taskArray							=	[];
			_dayTaskArray						=	[];
			tablePageTurner						=	new NxTablePageTurner(purePage, nextPage,taskList,pageNum,null,showFristInfo);
			taskTab.addItem(StaticIni.getSwfLangStr(_haveTaskStr), -1, StaticIni.getSwfLangStr(_haveTaskStr));
			taskTab.addItem(StaticIni.getSwfLangStr(_canTaskStr), -1, StaticIni.getSwfLangStr(_canTaskStr));
			//taskTab.addItem(StaticIni.getSwfLangStr("UIStr_1000144"), -1, StaticIni.getSwfLangStr("UIStr_1000144"));
			backFrame_1.mouseEnabled	=	false;
			checkBox.gotoAndStop(2);
			isShowTracking();
			giveStrTitle.htmlText = StaticIni.getSwfLangStr("TaskUI_TaskBonus");
		}
		
		/**
		 *	更新任务进度 
		 * @param PropertiesName
		 * @param PropertiesValue
		 * @param data
		 * 
		 */
		private function updataTaskTrack(PropertiesName:String,PropertiesValue:*,data:*) : void
		{
			if(_currTaskId == PropertiesValue[0])
			{
				showTaskInfo(_currTaskId);
				taskTab.selected	=	taskTab.selected;
				checkTaskIndexPage(_currTaskId,_haveTaskArray)
			}
		}
		
		override protected function BeforeShow():void 
		{
			
			addListener()
			SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_DAILY_TASK_AUTOTIME_QUERY);
			taskTab.selected	=	_showTabIndex;
		}
		override protected function AfterHide():void 
		{
			_lineTaskType		=	-1;
			_linkTaskID			=	-1;
			_showTabIndex		=	0;
			_linkTaskAuto		=	false;
			removeListener();
			_bind.UnbindRecord("Task_Accepted", _haveTaskList);
		}
		
		/**
		 * 当前任务列表
		 * @param	e
		 */
		private function getTaskList(e:CustomMsgEvent):void
		{
			_haveTaskArray			=	[];
			var taskListArray:Array	=	e.pList;
			taskListArray.shift();
			var taskLength:int		=	taskListArray.length;
			var taskType:String		=	"";
			var taskID:int			=	0;
			var taskName:String		=	"";
			var overType:int		=	0;
			var overStr:String		=	"";
			//taskItemObj["name"]		=	"<font size='14'>"+_taskLogic.getTaskType(taskItemArray) + getCompletedSuffix(taskID) +"</>";
			for (var i:int = 0; i < taskListArray.length; i+=4) 
			{
					var taskItemObj:Object	=	{ };
					taskType	=	taskListArray[i];
					taskID		=	taskListArray[i + 1];
					taskName 	= 	StaticIni.getSwfLangStr("Task_Caption" + taskID);
					taskItemObj["taskType"]	=	NOW_TASK;
					taskItemObj["type"]		=	taskType
					//悬赏任务不显示	
					if("1-20" == taskType)	continue
					taskItemObj["id"]		=	taskID
					
					//完成状态
					if (taskListArray[i+2] == -1) 
					{
						overType	=	-1;
						overStr		=	StaticIni.getSwfLangStr("Common_Complete")
					}
					else
					{
						if (taskListArray[i+3] == 1) 
						{
							overType	=	1;
							overStr		=	StaticIni.getSwfLangStr("Common_Fail")
						}
						else
						{
							overType	=	0;
						}
					}
					taskItemObj["name"]		=	"<font color='#C1981A' size='14'><b>" + _taskLogic.getTaskTypeDisp(taskName, taskType) +getCompleteStr(overType)+ "</b></>";
			
					taskItemObj["overType"]	=	overType ; 
					
					_haveTaskArray.push(taskItemObj);
			}
			_haveTaskArray.sortOn("type");
			//如果为当前类型，刷新显示列表
			if (taskTab.dataProvider[taskTab.selected]["data"] == StaticIni.getSwfLangStr(_haveTaskStr)) 
			{
				showDataType();
				if (_lineTaskType == 0) 
				{
					checkTaskIndexPage(_linkTaskID, _haveTaskArray);
//					if(_linkTaskAuto && autoOverBtn.enabled)
//					{
//						if (taskTab.dataProvider[taskTab.selected]["data"] == StaticIni.getSwfLangStr(_haveTaskStr))
//						{
//							autoOverBtn.dispatchEvent(new MouseEvent(MouseEvent.CLICK));
//						}
//					}
				}
			}
		}
		/**
		 * 可接任务列表
		 * @param	e
		 */
		private function getCanableList(e:CustomMsgEvent):void
		{
//			taskItemStr += 
//			levelPlay>= needLv ?"<font color='#1eff00'>(Lv:" + needLv +")</font>" :"<font color='#FF0000'>(Lv:" + needLv +")</font>";
			_taskArray				=	[];
			var taskListArray:Array	=	e.pList;
			var taskLength:int		=	taskListArray.length;
			var taskType:String		=	"";
			var taskID:int			=	0;
			var taskName:String		=	"";
			var levelPlay:int	=	_model.scene.Role.getPlayerLevel();
			var needLv:int ;
			var prTaskItem:Object	=	{ };
			
			for (var i:int = 1; i < taskLength; i+=2)
			{
				var str:String="";
				var taskItemObj:Object	=	{ };
				taskType	=	taskListArray[i];
				taskID		=	taskListArray[i + 1];
			
				if(taskType == "")  continue;
				
				taskName 	= 	StaticIni.getSwfLangStr("Task_Caption" + taskID);
				taskItemObj["taskType"]	=	CAN_TASK;
				taskItemObj["type"]		=	taskType
				taskItemObj["id"]		=	taskID
				if (taskType == "1-1")
				{
					prTaskItem	=	StaticIni.getIniObj(String("Jxtask_"+taskID));
					needLv		=	prTaskItem["Level"]
					str=levelPlay>=needLv?"":"<font color='#FF0000'>(Lv:" + needLv +")</font>";
					taskItemObj["name"]		=	"<font color='#C1981A' size='14'><b>" + _taskLogic.getTaskTypeDisp(taskName, taskType)+str+"</b></>";
				}else
				{
					taskItemObj["name"]		=	"<font color='#C1981A' size='14'><b>" + _taskLogic.getTaskTypeDisp(taskName, taskType)+ "</b></>";
				}
//				taskItemObj["name"]		=	"<font color='#C1981A' size='14'><b>" + _taskLogic.getTaskTypeDisp(taskName, taskType)+ "</b></>";
				taskItemObj["overType"]	=	0
				_taskArray.push(taskItemObj);
			}
			_taskArray.sortOn("type");
			//如果为当前类型，刷新显示列表
			if (taskTab.dataProvider[taskTab.selected]["data"] == StaticIni.getSwfLangStr(_canTaskStr)) 
			{
				showDataType();
			}
		}
		/**
		 * 日常任务列表
		 * @param	e
		 */
		private function getDayList(e:CustomMsgEvent):void
		{
			_dayTaskArray			=	[];
			var taskListArray:Array	=	e.pList;
			taskListArray.shift();
			var taskLength:int		=	taskListArray.length;
			var taskType:String		=	"";
			var taskID:int			=	0;
			var taskName:String		=	"";
			var taskInfo:String		=	"";
			for (var i:int = 0; i < taskLength; i+=6) 
			{
				var taskItemObj:Object	=	{ };
				taskType	=	taskListArray[i];
				taskID		=	taskListArray[i + 1];
				taskName	= 	StaticIni.getSwfLangStr("Task_Caption" + taskID);
				taskItemObj["taskType"]	=	DAY_TASK;
				taskItemObj["type"]		=	taskType
				taskItemObj["id"]		=	taskID
				var isAccp:String		=	taskListArray[i + 2];
				var canAccp:String		=	taskListArray[i + 3];
				var canComp:String		=	taskListArray[i + 4];
				var falled:int			=	taskListArray[i + 5];
				if (falled == -1) 
				{
					//失败了
					taskInfo				=	StaticIni.getSwfLangStr("Common_Fail");
					taskItemObj["overType"]	=	-1;
				}
				else
				{
					switch (isAccp + canAccp +canComp) 
					{
						case "000":
						case "001":
							//完成过了
							taskInfo	=	StaticIni.getSwfLangStr("UIStr_1000028")
							taskItemObj["overType"]	=	4;
							break;
						case "010":
						case "011":
							//可接
							taskInfo	=	StaticIni.getSwfLangStr("UIStr_1001772")
							taskItemObj["overType"]	=	3;
							break;
						case "100":
						case "110":
							//已接
							taskInfo	=	StaticIni.getSwfLangStr("UIStr_1001771");
							taskItemObj["overType"]	=	2;
							break;
						case "101":
						case "111":
							//可提交完成了
							taskInfo	=	StaticIni.getSwfLangStr("UIStr_1001770")
							taskItemObj["overType"]	=	1;
						break;
						default:
					}
				}

				taskItemObj["name"]		=	"<font color='#C1981A' size='14'><b>" + taskName+ taskInfo+"</b></>";
				//完成过的就不显示了
				if (taskItemObj["overType"]	!=	4) 
				{
					_dayTaskArray.push(taskItemObj);
				}
			}
			_dayTaskArray.sortOn("overType", Array.NUMERIC);
			//如果为当前类型，刷新显示列表
			if (taskTab.dataProvider[taskTab.selected]["data"] == StaticIni.getSwfLangStr("UIStr_1000144")) 
			{
				showDataType();
				if (_lineTaskType == 2) 
				{
					checkTaskIndexPage(_linkTaskID, _dayTaskArray);
				}
			}
		}
		/**
		 * 当任务列表有变化时
		 * @param	e
		 */
		private function taskListChange(e:CustomMsgEvent):void
		{
			taskTab.selected	=	taskTab.selected;
		}
		/**
		 * 根据页签显示相应的数据
		 */
		private function showDataType():void
		{
			var tabSelectType:String	=	taskTab.dataProvider[taskTab.selected]["data"];
			var dataLenght:int			=	0;
			var showData:Array
			taskList.dataProvider		=	null;
			//判读类型
			switch (tabSelectType) 
			{
				case StaticIni.getSwfLangStr(_haveTaskStr):
					showData	=	_haveTaskArray;
				break;
				case StaticIni.getSwfLangStr(_canTaskStr):
					showData	=	_taskArray;
				break;
				case StaticIni.getSwfLangStr("UIStr_1000144"):
					showData	=	_dayTaskArray;
				break;
			}
			//显示数据
			dataLenght	=	showData.length;
			for (var i:int = 0; i < dataLenght; i++)
			{
				taskList.addLineByIndex([showData[i]["name"]], -1, showData[i]);
			}
			
			taskList.currentPos	=	new NxTabelPos(0, 0);
			tablePageTurner.onPageDis();
		}
		/**
		 *取得完成后缀 
		 * @param taskID	任务ID
		 * @return 			完成后缀
		 */	
		private function getCompletedSuffix(taskID:int):String
		{
			var suffixRtn:String = "";
			var taskStatus:int = getTaskStatus(taskID);
			
			// 若任务已完成，加上已完成后缀
			if (taskStatus == 1)
			{
				var suffix:String = StaticIni.getSwfLangStr("Common_Complete");
				
				suffixRtn = StaticIni.getSwfLangStrVar("textcolor", 
					["#"+StaticIni.getIniVar("Css_txt_Task_schedule","suffix"), suffix]);
			}
			// 若任务失败，加上失败后缀 
			else if (taskStatus == -1)
			{
				var suffixFail:String = StaticIni.getSwfLangStr("Common_Fail");
				
				suffixRtn = StaticIni.getSwfLangStrVar("textcolor", 
					["#"+StaticIni.getIniVar("Css_txt_Task_schedule","suffix"), suffixFail]);
			}
			
			return suffixRtn;
		}
		/**
		 * 完成的字串
		 * @return
		 */
		private function getCompleteStr(val:int):String
		{
			var suffixRtn:String = "";

			// 若任务已完成，加上已完成后缀
			if (val == 1)
			{
				var suffix:String = StaticIni.getSwfLangStr("Common_Complete");
				
				suffixRtn = StaticIni.getSwfLangStrVar("textcolor", 
					["#"+StaticIni.getIniVar("Css_txt_Task_schedule","suffix"), suffix]);
			}
			// 若任务失败，加上失败后缀 
			else if (val == -1)
			{
				var suffixFail:String = StaticIni.getSwfLangStr("Common_Fail");
				
				suffixRtn = StaticIni.getSwfLangStrVar("textcolor", 
					["#"+StaticIni.getIniVar("Css_txt_Task_schedule","suffix"), suffixFail]);
			}
			return suffixRtn;
		}
		/**
		 * 取得任务进行状态 
		 *  @param taskID
		 *  @return -1:失败 0：未完成 1:完成
		 * 
		 */
		private function getTaskStatus(taskID:int):int
		{			
			if (taskID < 1)
			{
				return 0;
			}
			// 取任务进度表
			var taskRec:Record = _model.scene.GetRecordEx("Task_Accepted");
			
			var recRows:int = taskRec.recArr.length;
			
			for (var row:int = 0; row < recRows; row++)
			{
				var curTaskID:int = taskRec.recArr[row][0];
				if (curTaskID != taskID)
				{
					continue;	
				}
				
				// 任务状态标记
				var taskStatus:int = taskRec.recArr[row][1];
				
				return taskStatus;
			}
			
			return 0;				
		}
				/**
		 * 获取[天\时\分\秒] 
		 * @param val 以秒为单位的整数
		 * @return [天\时\分\秒]
		 * 
		 */		
		private function getDHMS(val:int):Array
		{
			val	=	val<0	?	0	:	val;
			
			var d:int	=	int(	val				/(60*60*24)	);
			var h:int	=	int(	val%(60*60*24)/(60*60)		);
			var m:int	=	int(	val%(60*60)	/60				);
			var s:int	=	int(	val%60						);
			
			return [d,h,m,s];
		}
		/**
		 * 取得任务进度信息
		 * @param 	taskID
		 * @return	进度描述字符串
		 * 
		 */
		public function getTaskSchedule(taskID:int):String
		{
			var scheduleRtn:String = "";
			
			if (taskID < 1)
			{
				return scheduleRtn;
			}
			
			// 取任务进度表
			var taskRec:Record = _model.scene.GetRecordEx("Task_Record");
			
			var recRows:int = taskRec.recArr.length;
			for (var row:int = 0; row < recRows; row++)
			{
				var curTaskID:int = taskRec.recArr[row][0];
				if (curTaskID != taskID)
				{
					continue;	
				}
				
				var type:String			= taskRec.recArr[row][1];	// 类型
				var CustomTaskType:int	= taskRec.recArr[row][2]	//自定义任务 类型
				var curAmount:String	= taskRec.recArr[row][3]	// 当前进度
				var totalAmount:String	= taskRec.recArr[row][4]	// 总进度
				var key:String 			= taskRec.recArr[row][5]	// 关键字描述
				
				var keyStr:String;
				if(type == GameDefine.TASKTYPE_CUSTOM.toString())
				{// 判断是不是自定义任务类型
					keyStr	= StaticIni.getSwfLangStr("CustomTask_"+CustomTaskType);
				}else
				{
					keyStr	= StaticIni.getSwfLangStr(key);
				}
				//				var keyStr:String 		= StaticIni.getSwfLangStr(key);
				
				// 非猎杀类或收集类任务，无需显示任务进度
				if (int(type)  	!= 	GameDefine.TASKTYPE_HUNT &&
					int(type)  	!= 	GameDefine.TASKTYPE_COLLECT&&
					int(type)	!= GameDefine.TASKTYPE_CUSTOM)
				{
					return "";
				}
				
				// 根据完成状况，设置颜色
				var txtColor:String		= "";
				if (curAmount < totalAmount)
				{
					txtColor = StaticIni.getIniVar("Css_txt_Task_schedule", "uncomplete");
				}
				else
				{
					txtColor = StaticIni.getIniVar("Css_txt_Task_schedule", "complete");
				}
				
				var args:Array		= new Array();
				args.push(txtColor);
				args.push(curAmount);
				args.push(totalAmount);
				args.push(keyStr);
				
				// 进度描述
				var scheduleStr:String	= "";
				scheduleStr = StaticIni.getSwfLangStrVar("Task_schedule_1", args);

				scheduleRtn +=  "<br>" + scheduleStr;
			}
			
			return scheduleRtn;
		}
		/**
		 * 添加奖励装备图片
		 * @param	index
		 * @param	src
		 * @param	desc
		 * @param	num
		 */
		private function setPrizeEquip(index:uint,src:String, desc:String , prizeCount:String):void
		{
			equipPicGroup.visible = true;
			var item:MovieClip		=	equipPicGroup.getItemByIndex(index);
			
			var img:NxClip			= item["img"]	;
			var prizeNum:NxLabel		= item["prizeNum"];
			if(img == null)
			{
				img = new NxClip();
				item.addChild(img);
				item["img"] = img;
			}
			if(prizeNum == null)
			{
				prizeNum = new NxLabel();
				item.addChild(prizeNum);
				item["prizeNum"] = prizeNum;
			}
			prizeNum.x = prizeNum.y = 30;
			prizeNum.text = prizeCount;
			img.x	=	img.y	=	5;
			img.source				=	ResManager.newResClass(src);
		}
		/**
		 * 任务的剩下时间
		 * @param	e
		 */
		private function serverTimeHandle(e:CustomMsgEvent):void 
		{
			if(_taskEndTime	< 0)	return;
			
			var serverTime	:uint	=	e.pList[0];
			_leftTime		=	_taskEndTime-serverTime;
			
			if(_leftTime>0)
			{
				_times	=	0;
				
				_taskOverTimer.reset();
				
				_taskOverTimer.repeatCount=_leftTime;
				_taskOverTimer.start();
				leftTimeLb.visible	=	true;
//				leftTimeTxt.visible	=	true;
//				leftTimeTxt.htmlText=StaticIni.getSwfLangStrVar("UIStr_1001317",getDHMS(_leftTime)	);
			}
		}
		/**
		 * 自动完成剩余时间
		 * @param	e
		 */
		private function showAutoTime(e:CustomMsgEvent):void 
		{
			_autotime	=	e.pList[0];
			if(_autotime > 0)
			{
				if(!_autoTimer.running)
					_autoTimer.start();
			}
			else
			{
				_autoTimer.stop();
				autoTimerGo();
			}
		}
		/**
		 * 完成任务
		 * @param	e
		 */
		private function autoTimerGo(e:TimerEvent=null):void
		{
			_autotime--;
			if(_autotime > 0)
			{
//				autoFTTime.htmlStr = StaticIni.getSwfLangStrVar("UIStr_1001549",[String(int(_autotime / 60)),(_autotime%60>9)?String(_autotime % 60):"0"+String(_autotime % 60)]);
//				autoOverBtn.enabled = false;
			}
			else
			{
				_autotime = 0;
//				autoFTTime.htmlStr = ""; 
//				autoOverBtn.enabled = true;
				_autoTimer.stop();
			}
		}
		private function taskTimeHandle(e:TimerEvent):void
		{
			_times		++;
			if(_times >9)
			{
				SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_QUERYSERVERTIME);
				_times	=	0;
			}
			_leftTime	--;
//			leftTimeTxt.htmlText=StaticIni.getSwfLangStrVar("UIStr_1001317",getDHMS(_leftTime)	);
		}
		/**
		 * 接取，提交,自动完成
		 * @param	e
		 */
		private function btnClickHandle(e:MouseEvent):void 
		{
			//_clickTaskItem	=	taskList.getItemDataFromEx_Page(_tablePos,taskList.currentPage);
			//if (_clickTaskItem == null) 
			//{
				//return;
			//}
			//if (e.currentTarget == sendBtn) 
			//{
				//if (sendBtn.label == StaticIni.getSwfLangStr("TaskComUI_SendTask")) 
				//{
					//提交
					//SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_TASK_CONFIRM_COMPLETE,0,_clickTaskItem["id"],0)
				//}
				//else if (sendBtn.label == StaticIni.getSwfLangStr("UIStr_1001199"))
				//{
					//if (taskTab.dataProvider[taskTab.selected]["data"] == StaticIni.getSwfLangStr("UIStr_1000144")) 
					//{
						//日常任务的接取
						//SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_ACCEPT_DAILY_COMMON_TASK,_clickTaskItem["id"])
					//}
					//else
					//{
						//普通任务的接取
						//SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_TASK_CONFIRM_ACCEPT,_clickTaskItem["id"])
					//}}
				//else if (sendBtn.label == StaticIni.getSwfLangStr("TaskUI_TaskGiveUp"))
				//{
					//放弃
					//SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_TASK_GIVEUP, _clickTaskItem["id"]);
				//}
			//}
			//else if(e.currentTarget == autoOverBtn)
			//{
				//自动完成
				//SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_DAILY_TASK_AUTO, _clickTaskItem["id"]);
			//}
		}
		/**
		 * 关闭窗体
		 * @param	e
		 */
		private function closeHandle(e:NxWindowEvent):void 
		{
			this.hide();
		}
		/**
		 * 表格事件
		 * @param	e
		 */
		private function tableClickHandle(e:NxTableEvent):void 
		{
			initTaskInfo();
			if (e) 
			{
				
				if (e.lineArrData != null) 
				{
					var taskItem:Object	=	e.lineArrData[0]["data"];
					_clickTaskItem		=	taskItem;
					if (taskItem == null)return 
					showTaskInfo(taskItem["id"]);
					//checkButtonEnable(taskItem);
					if (taskTab.dataProvider[taskTab.selected]["data"] == StaticIni.getSwfLangStr(_haveTaskStr)) 
					{
						giveUpBtn.visible	=	true;
					}
				}
			}
		}
		/**
		 * 判断当前按钮的显示状态与相应的字符
		 * @param	val
		 */
		private function checkButtonEnable(val:Object):void
		{
			//-1:失败 0：未完成 1:完成 2,可接，3已接
			
			_clickTaskItem	=	val;
			if (val == null) return; 
			var type:String		=	val["type"];
			var taskType:String	=	val["taskType"];
			var taskOver:int	=	val["overType"];
			switch (taskType) 
			{
				case NOW_TASK:
					giveUpBtn.visible	=	true;
					break;
				default:
					giveUpBtn.visible	=	false;
			}
			//switch (taskType) 
			//{
				//case NOW_TASK:
					//
					//sendBtn.visible	=	true;
					//sendBtn.enabled	=	true;
					//if (type == "1-2") 
					//{
						//autoOverBtn.visible	=	true;
						//autoFTTime.visible	=	true;
					//}
					//else
					//{
						//autoOverBtn.visible	=	false;
						//autoFTTime.visible	=	false;
					//}
//
					//放弃任务
					//sendBtn.label	=	StaticIni.getSwfLangStr("TaskUI_TaskGiveUp")
					//break;
				//case CAN_TASK:
					//sendBtn.visible	=	false;
					//sendBtn.enabled	=	false;
					//autoOverBtn.visible	=	false;
					//autoFTTime.visible	=	false;
					//taskOverBtn.label	=	StaticIni.getSwfLangStr("UIStr_1001199")
					//taskOverBtn.visible	=	true;
					//taskOverBtn.enabled	=	true;
					//break;
				//case DAY_TASK:
					//autoOverBtn.visible	=	false;
					//autoFTTime.visible	=	false;
					//sendBtn.visible		=	true;
					//sendBtn.enabled		=	true;
					//if (taskOver == -1)
					//{
						//完成失败的放弃任务
						//sendBtn.label	=	StaticIni.getSwfLangStr("TaskUI_TaskGiveUp")
					//}
					//else if(taskOver == 1)
					//{
						//sendBtn.label	=	StaticIni.getSwfLangStr("TaskComUI_SendTask")
					//}
					//else if(taskOver == 3)
					//{
						//sendBtn.label	=	StaticIni.getSwfLangStr("UIStr_1001199")
					//}
					//else if (taskOver == 2 || taskOver == 4)
					//{
						//接取后的任务也要可以放弃
						//sendBtn.label	=	StaticIni.getSwfLangStr("TaskUI_TaskGiveUp")
					//}
					//break;
				//default:
			//}
		}
		/**
		 * 点击文本链接时调用 
		 * @param e
		 * 
		 */		
		public function onTxtPramLinkClick(val:String):void
		{
			if(val == "") return;
			var eveStr:Object	=	StaticIni.getIniObj(val);
			SceneTransfer.getInstance().tranferTo(val);
		}
		/**
		 * 显示任务信息内容
		 */
		private function showTaskInfo(taskId:int):void
		{
			_currTaskId = taskId;
//			equipInfoTxt.visible	=	true;
			equipPicGroup.visible	=	true;
			var txtStyle:StyleSheet	=	new StyleSheet();
			
			txtStyle.setStyle("a:link"		,{color:"#"+StaticIni.getIniVar("Css_a_Task","link"),textDecoration:"underline"});
			txtStyle.setStyle("a:visited"	,{color:"#"+StaticIni.getIniVar("Css_a_Task","visited")});
			txtStyle.setStyle("a:hover"	, { color:"#" + StaticIni.getIniVar("Css_a_Task", "hover"), textDecoration:"none" });
			
			taskInfoText.styleSheet	=	txtStyle;
			taskNeedText.styleSheet	=	txtStyle;
			// 任务描述
			var taskContext:String	=	"        "+StaticIni.getSwfLangStr("Task_Context" + taskId);
			
			
			// 接取NPC
			var acceptNPC:String	=	StaticIni.getSwfLangStr("Task_AcceptNpc" + taskId);
			// 提交NPC
			var submitNPC:String	=	StaticIni.getSwfLangStr("Task_SubmitNpc" + taskId);
			// 任务要求
			var taskSummar:String	=	"        "+ StaticIni.getSwfLangStr("Task_Summar" + taskId);
			// 任务进度
			var schedule:String 	= 	getTaskSchedule(taskId);
			// 奖励元宝 YCG
			var prizeMoney:int 		= 	int(StaticIni.getIniVar("taskprize_"+taskId,"MagicCoin"));
			//绑定金币
			var boundMoney:int		=	int(StaticIni.getIniVar("taskprize_"+taskId,"boundmoney"));
			// 奖励精力
			var prizeExp:int		= 	int(StaticIni.getIniVar("taskprize_"+taskId,"exp"));
			
			//奖励声望
			var peerexp	:int		=	int(StaticIni.getIniVar("taskprize_"+taskId,"peerexp"));
			//奖励功勋
			var exploit:int			=	int(StaticIni.getIniVar("taskprize_"+taskId,"exploit"));
			
			//城堡任务奖励
			//城堡贡献值
			var castlePoint:int = int(StaticIni.getIniVar("taskprize_"+taskId,"castlePoint"));
			//食物资源
			var castleResource_Farm:int = int(StaticIni.getIniVar("taskprize_"+taskId,"castleResource_Farm"));
			//军事训练值
			var castleResource_Stone:int = int(StaticIni.getIniVar("taskprize_"+taskId,"castleResource_Stone"));
			//石料资源
			var castleResource_Knight:int = int(StaticIni.getIniVar("taskprize_"+taskId,"castleResource_Knight"));
			//技术研究值
			var castleResource_Tech:int = int(StaticIni.getIniVar("taskprize_"+taskId,"castleResource_Tech"));
			
			// 扩展描述
			var addInfo1	:String	=	StaticIni.getIniVar("taskprize_" + taskId, "addInfo1");
			var infoString:String 	=	"";
			var taskNeedStr:String	=	"";
			var giveStr		:String	=	"";
			infoString			=	StaticIni.getSwfLangStrVar("Task_Info_TaskUI_2",			
										[taskContext]);
			taskInfoText.htmlText	=	infoString;
			
			taskNeedStr			=	StaticIni.getSwfLangStrVar("Task_Info_TaskUI_3",			
										[taskSummar,acceptNPC, submitNPC, schedule]);
										

			if(prizeMoney>0)
			{
				giveStr		+=	StaticIni.getSwfLangStrVar("Task_prizeMagicCoin",[prizeMoney]);
			}
			if(boundMoney>0)
			{
				giveStr		+=	StaticIni.getSwfLangStrVar("Task_prizeCoin",[boundMoney]);
			}
			if(prizeExp>0)
			{
				giveStr		+=	StaticIni.getSwfLangStrVar("Task_prizeExp",[prizeExp]);
			}
			if(castlePoint > 0)
			{
				giveStr		+=	StaticIni.getSwfLangStrVar("Task_prizeCastlePoint",[castlePoint]);
			}
			if(peerexp > 0)
			{
				giveStr		+=	StaticIni.getSwfLangStrVar("Task_prizeExploit",[peerexp]);
			}
			if(castleResource_Farm > 0)
			{
				giveStr		+=	StaticIni.getSwfLangStrVar("Task_prizeCastleResource_Farm",[castleResource_Farm]);
			}
			if(castleResource_Stone > 0)
			{
				giveStr		+=	StaticIni.getSwfLangStrVar("Task_prizeCastleResource_Stone",[castleResource_Stone]);
			}
			if(castleResource_Knight > 0)
			{
				giveStr		+=	StaticIni.getSwfLangStrVar("Task_prizeCastleResource_Knight",[castleResource_Knight]);
			}
			if(castleResource_Tech > 0)
			{
				giveStr		+=	StaticIni.getSwfLangStrVar("Task_prizeCastleResource_Tech",[castleResource_Tech]);
			}
			if(exploit > 0)
			{
				giveStr		+=	StaticIni.getSwfLangStrVar("Task_prizeExploit_8",[exploit]);
			}
			//判断 奇遇任务奖励
			if(giveStr=="")
			{
//				var obj:Object= StaticIni.getIniObj("AdventureTaskPrepareItemID"); 
//				if(obj[taskId]!=null)
//				{
//					giveStrLabel.htmlText	=StaticIni.getSwfLangStrVar("UIString_1000448",[StaticIni.getSwfLangStr(obj[taskId].toString())])
//				}
			}else
			{
				giveStrLabel.htmlText	=	giveStr;
			}
			
			if(addInfo1.length>0)
			{
				taskNeedStr		+=	"<br>"+StaticIni.getSwfLangStr(addInfo1);
			}
			taskNeedText.htmlText	=	taskNeedStr;
			// 奖励装备
			var taskPrizeStr:String	=	StaticIni.getIniVar("taskprize_"+taskId,"item");
			var taskPrizeNum:String	=	StaticIni.getIniVar("taskprize_"+taskId,"amount");
			equipPicGroup.visible = false;
			if(taskPrizeStr != null && taskPrizeStr != "")
			{
				equipPicGroup.visible = true;
				//奖励物品id 1231,231
				var taskPrizeArr:Array	=	taskPrizeStr.split(",");
				//奖励物品个数 3,1 与奖励物品一一对应
				var taskPriNuArr:Array	=	new Array();
				if(taskPrizeNum != null	&&	taskPrizeNum != "")
				{
					taskPriNuArr	=	taskPrizeNum.split(",");
				}
				else
				{
					taskPriNuArr	=	null;
				}
				_prizeItemArr			= 	taskPrizeArr;
				for(var i:int=0;i<taskPrizeArr.length;i++)
				{
					var tmpPrize:Object	=	StaticIni.getIniObj(taskPrizeArr[i]);
					var tmpPriNm:String	;
					if (tmpPrize == null)
					{
						continue;
					}
					if(taskPriNuArr == null)
					{
						tmpPriNm	=	"";
					}
					else
					{
						tmpPriNm	=	taskPriNuArr[i];
					}
					setPrizeEquip(i,"icon_"+tmpPrize["Photo"],tmpPrize["NameID"],tmpPriNm);
					if (equipPicGroup.getItemByIndex(i) != null)
					{
						equipPicGroup.getItemByIndex(i).data 	= tmpPrize;
						equipPicGroup.getItemByIndex(i).id	= i;
						
						// 增加Tips监听
						equipPicGroup.getItemByIndex(i).addEventListener(MouseEvent.ROLL_OVER, onItemOver);
						equipPicGroup.getItemByIndex(i).addEventListener(MouseEvent.ROLL_OUT, onItemOut);
					}
				}
			}
			
			if (taskTab.dataProvider[taskTab.selected]["data"]	==	StaticIni.getSwfLangStr(_haveTaskStr) ||
				taskTab.dataProvider[taskTab.selected]["data"]	==	StaticIni.getSwfLangStr("UIStr_1000144")
				)
			{
				
				//SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_DAILY_TASK_AUTO, taskId);
//				var taskTimeRecord	:Record	=	_model.scene.GetRecordEx("TaskTimeLimit");
//				var maxRow	:int			=	taskTimeRecord.recArr.length;
//				for(var j:int=0;	j<maxRow;	j++)
//				{
//					if(taskId	==	taskTimeRecord.recArr[j][0])
//					{
//						_taskEndTime	=	taskTimeRecord.recArr[j][2];
//						break;
//					}
//				}
//				if(_taskEndTime>0)
//				{
//					SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_QUERYSERVERTIME);
//				}
			}
		}
		/**
		 * 显示装备Tips 
		 * @param e
		 * 
		 */		
		private function onItemOver(e:MouseEvent):void
		{
			var item:MovieClip	=	e.currentTarget as MovieClip;
			
			//和谐
			var tObj:BaseObject = BaseObject.fromObj(item.data);
			if(tObj!=null && _prizeItemArr[item.id] > 0)
			{
//				if (tObj.CheckProperties("EquipType") && tObj.GetProperties("EquipType") != "")
//				{					
//					TipsManage.ShowItemMaxTips(tObj,_prizeItemArr);
//				}
//				else
//				{
//					TipsManage.ShowItemTips(_prizeItemArr[item.id]);
					TipsMainLogic.instance.showMain(_prizeItemArr[item.id]);
//				}
			}
		}
		
		/**
		 * 隐藏装备Tips 
		 * @param e
		 * 
		 */		
		private function onItemOut(e:MouseEvent):void
		{
			TipsMainLogic.instance.hide()
		}
		/**
		 * 清空信息内容
		 */
		private function initTaskInfo():void 
		{
			leftTimeLb.visible 		= false;
//			leftTimeTxt.htmlText	=	"";
			_taskEndTime			=	-1;
			_taskOverTimer.stop();
			//sendBtn.visible			=	false;
			//autoOverBtn.visible		=	false;
//			autoFTTime.visible		=	false;
			taskNeedText.htmlText	=	"";
			taskInfoText.htmlText	=	"";
			giveStrLabel.htmlText	=	"";
//			equipInfoTxt.visible	=	false;
			equipPicGroup.visible	=	false;
			giveUpBtn.visible		=	false;
			equipPicGroup.getItemForEach(function(val:MovieClip):void
			{
				var nxclip:NxClip = val["img"] as NxClip;
				var nxLab:NxLabel = val["prizeNum"]		as NxLabel
				if(nxclip)
				{
//					if(nxclip.parent)
//					{
//						val.removeChild(nxclip);
//					}
					nxclip.source = null;
				}
				if(nxLab)
				{
					nxLab.text = "";
				}
			});
//			 清除装备图片Tips监听
			var length:int = _prizeItemArr.length;
			if (length > 0)
			{
				for (var i:int = 0; i < length; i++)
				{
					var clip:MovieClip	= equipPicGroup.getChildAt(i) as MovieClip;
					if (clip != null)
					{
						clip.removeEventListener(MouseEvent.ROLL_OVER,onItemOver);
						clip.removeEventListener(MouseEvent.ROLL_OUT,onItemOut);
					}
				}
				_prizeItemArr.splice(0);
			}
		}
		private function showFristInfo():void
		{
			taskList.currentPos	=	new NxTabelPos(0, 0);
		}
			
		/**
		 *模拟跳转任务 
		 * @param taskId
		 * 
		 */
		public function gotoTask(taskId:String,autoCommplete:Boolean = false):void
		{
			var taskInfo:Array	=	taskId.split("_");
			var taskID:int		=	-1
			var tabType:int		=	-1
			
			taskID				=	int(taskInfo[0]);
			tabType				=	int(taskInfo[1]);
			
			_lineTaskType		=	tabType;
			_linkTaskID			=	taskID;
			_showTabIndex		=	_lineTaskType;
			_linkTaskAuto	=	autoCommplete;
			show();
		}
		/**
		 * 根据任务号来打开相应的页码和索引
		 * @param	taskID
		 * @param	taskArray
		 * @return
		 */
		private function checkTaskIndexPage(taskID:int,taskArray:Array):void
		{
			var taskIndex:int	=	getTaskIndex(String(taskID),taskArray);
			var nowPage		:int;
			var clickX		:int;
			nowPage			= Math.ceil((taskIndex+1)/taskList.pageLinesConut)-1;
			taskList.currentPage = nowPage;
			if(taskIndex <= taskList.pageLinesConut-1)
			{
				clickX = taskIndex;			
			}
			else
			{
				clickX = (taskIndex)%(taskList.pageLinesConut);
			}
			tablePageTurner.onPageDis();
			taskList.currentPos = new NxTabelPos(clickX, 0);
			_linkTaskID		=	-1;
			_lineTaskType	=	-1;
		}
		/**
		 * 可接任务
		 */
		public function gotoCanTask():void
		{
			_showTabIndex	=	1;
			show();
		}
		/**
		 *获得任务在列表中的索引 
		 * @param taskid
		 * @return 
		 */
		private function getTaskIndex(taskid:String,taskArray:Array):int
		{
			var taskArr:Array = taskArray;
			var index :int;
			for(var i:int = 0;i< taskArr.length;i++)
			{
				if(taskArr[i]["id"] == taskid)
				{
					index = i;
					break;
				}
			}
			return index;
		}
		/**
		 * 页签事件
		 * @param	e
		 */
		private function tabClickHandle(e:NxTabEvent):void 
		{
			var tabClickType:String	=	taskTab.dataProvider[e.seleted]["data"];
			taskList.dataProvider	=	null;
			initTaskInfo();
			/**YCG*/
			updateTaskList(tabClickType)
			//
			taskList.currentPos	=	new NxTabelPos(-1, -1);
			switch (tabClickType) 
			{
				case StaticIni.getSwfLangStr(_haveTaskStr):
					//checkBox.visible	= true;
					//label_1.visible		= true;
					SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_GET_CUR_TASK_LIST);
					break;
				case StaticIni.getSwfLangStr(_canTaskStr):
					//可接任务
					//checkBox.visible	= false;
					//label_1.visible		= false;
					SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_TASK_CAN_ACCEPT);
					break;
				case StaticIni.getSwfLangStr("UIStr_1000144"):
					//日常任务
					SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_GET_DAILY_COMMON_TASK_LIST);
					break;
				default:	
			}
			tablePageTurner.onPageDis()
		}
		/**
		 * 缓存当前任务列表 
		 * @param tabClickType
		 * 
		 */		
		private function updateTaskList(tabClickType:String):void
		{
			
			_haveTaskArray	//当前任务
			_taskArray //可接任务
			_dayTaskArray // 日常任务
			switch (tabClickType) 
			{
				case StaticIni.getSwfLangStr(_haveTaskStr):
					if(_haveTaskArray==null||_haveTaskArray.length==0)return ; 
					showDataType();
					break ; 
				case StaticIni.getSwfLangStr(_canTaskStr):
					if(_taskArray==null||_taskArray.length==0)return ; 
					showDataType();
					break ;
				case StaticIni.getSwfLangStr("UIStr_1000144"):
					if(_dayTaskArray==null||_dayTaskArray.length==0)return ; 
					showDataType();
					break ;
			}
		}
		/**
		 * 添加事件
		 */
		private function addListener():void
		{
			tablePageTurner.addEventListener();
			_model.addEventListener(String(CustomToClientFlag.SERVER_CUSTOMMSG_SEND_CUR_TASK_LIST), 	getTaskList);
			_model.addEventListener(String(CustomToClientFlag.SERVER_CUSTOMMSG_TASK_CAN_ACCEPT_LIST), getCanableList);
			_model.addEventListener(String(CustomToClientFlag.SERVER_CUSTOMMSG_SEND_DAILY_COMMON_TASK_LIST), getDayList);
			
			_model.addEventListener(String(CustomToClientFlag.SERVER_CUSTOMMSG_TASKLIST_CHANGE), taskListChange);
			
			_model.addEventListener(String(CustomToClientFlag.SERVER_CUSTOMMSG_SENDSERVERTIME), serverTimeHandle);
			_model.addEventListener(String(CustomToClientFlag.SERVER_CUSTOMMSG_TASK_AUTO_TIME),showAutoTime);
			
			windowBG.addEventListener(NxWindowEvent.WINDOW_CLOSE,		closeHandle);
			taskTab.addEventListener(NxTabEvent.TAB_CLICK, 				tabClickHandle);
			
			taskList.addEventListener(NxTableEvent.TABLE_CLICK,			tableClickHandle);
			taskList.addEventListener(NxTableEvent.TABLE_INDEX_CHANGE,	tableClickHandle);

			_taskOverTimer.addEventListener(TimerEvent.TIMER,			taskTimeHandle);
			giveUpBtn.addEventListener(MouseEvent.CLICK,				giveBtnClickHandle)
			_autoTimer.addEventListener(TimerEvent.TIMER, 				autoTimerGo);
			
			checkBox.addEventListener(MouseEvent.CLICK,					checkBoxClickHandle)
			taskInfoText.addLinkClickHandel(onTxtPramLinkClick);
			taskNeedText.addLinkClickHandel(onTxtPramLinkClick);
		}
		/**
		 * 放弃任务
		 * @param	e
		 */
		private function giveBtnClickHandle(e:MouseEvent):void 
		{
			if (_clickTaskItem == null) 
			{
				return;
			}
			else if (giveUpBtn.label == StaticIni.getSwfLangStr("TaskUI_TaskGiveUp"))
			{
				removeTaskArray();
				SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_TASK_GIVEUP, _clickTaskItem["id"]);
			}
		}
		/**
		 * 
		 *  如果当前任务只有一个你还放弃我就手动吧数组清空
		 */	
		private function removeTaskArray():void
		{
			if(_haveTaskArray.length==1)
			{
				_haveTaskArray=[];
			}
		}
		
		private function isShowTracking():void
		{
			//TaskTrackingUI.getInstance().isShowTracking	=	checkBox.currentFrame - 1;
		}
		/**
		 * 是否显示任务追踪
		 * @param	e
		 */
		private function checkBoxClickHandle(e:MouseEvent):void 
		{
			if (checkBox.currentFrame == 1) 
			{
				checkBox.gotoAndStop(2);
			}
			else if (checkBox.currentFrame == 2)
			{
				checkBox.gotoAndStop(1);
			}
			isShowTracking();
		}
		
		/**
		 * 删除事件
		 */
		private function removeListener():void
		{
			tablePageTurner.removeEventListener();
			_model.removeEventListener(String(CustomToClientFlag.SERVER_CUSTOMMSG_TASK_CAN_ACCEPT_LIST), getCanableList);
			_model.removeEventListener(String(CustomToClientFlag.SERVER_CUSTOMMSG_SEND_DAILY_COMMON_TASK_LIST), getDayList);
			_model.removeEventListener(String(CustomToClientFlag.SERVER_CUSTOMMSG_SENDSERVERTIME), serverTimeHandle);
			_model.removeEventListener(String(CustomToClientFlag.SERVER_CUSTOMMSG_TASKLIST_CHANGE), taskListChange);
			windowBG.removeEventListener(NxWindowEvent.WINDOW_CLOSE		,closeHandle);
			taskTab.removeEventListener(NxTabEvent.TAB_CLICK			, tabClickHandle);
			
			taskList.removeEventListener(NxTableEvent.TABLE_CLICK,			tableClickHandle);
			taskList.removeEventListener(NxTableEvent.TABLE_INDEX_CHANGE,	tableClickHandle);
			
			giveUpBtn.removeEventListener(MouseEvent.CLICK,					giveBtnClickHandle)
			_taskOverTimer.removeEventListener(TimerEvent.TIMER,			taskTimeHandle);
			_autoTimer.removeEventListener(TimerEvent.TIMER, 				autoTimerGo);
			
			taskInfoText.removeLinkClickHandel();
			taskNeedText.removeLinkClickHandel();
			checkBox.removeEventListener(MouseEvent.CLICK,					checkBoxClickHandle);
		}
	}

}